package com.qo.qsdk.utils;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;

import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsConstants;
import com.facebook.appevents.AppEventsLogger;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.messaging.FirebaseMessaging;
import com.qo.qsdk.http.QCommonResultBean;
import com.qo.qsdk.http.QResultCallback;
import com.qo.qsdk.http.QSDKHttp;
import com.qo.qsdk.ui.AccountActivity;

import org.jetbrains.annotations.NotNull;


public class FacebookManager {

    private static final String TAG = FacebookManager.class.getSimpleName();
    private Activity activity;

    private static class FacebookManagerHolder {
        private static final FacebookManager instance_ = new FacebookManager();
    }

    public static FacebookManager getInstance() {
        return FacebookManagerHolder.instance_;
    }

    private boolean open() {
        return true;
    }

    public FacebookManager() {

    }

    public void init(final Context activity) {
        if (open()) {
            FacebookSdk.setAutoLogAppEventsEnabled(true);
            FacebookSdk.setAdvertiserIDCollectionEnabled(true);
        }
    }

    public void log(Activity activity, String event) {
        log(activity, event, null);
    }

    public void log(Activity activity, String event, Bundle bundle) {
        if (open()) {
            AppEventsLogger.newLogger(activity).logEvent(event, bundle == null ? new Bundle() : bundle);
            try {
                Log.e(TAG, "fb:name:" + event + ",val->" + (bundle == null ? "" : bundle.toString()));
            }catch (Exception e){}
        }
    }
}
